<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Start a new pattern</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.ps-begin-page.html">ps_begin_page</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.ps-begin-template.html">ps_begin_template</a></div>
 <div class="up"><a href="ref.ps.html">PS 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.ps-begin-pattern" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ps_begin_pattern</h1>
  <p class="verinfo">(PECL ps &gt;= 1.2.0)</p><p class="refpurpose"><span class="refname">ps_begin_pattern</span> &mdash; <span class="dc-title">Start a new pattern</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.ps-begin-pattern-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">int</span> <span class="methodname"><strong>ps_begin_pattern</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$psdoc</code></span>
   , <span class="methodparam"><span class="type">float</span> <code class="parameter">$width</code></span>
   , <span class="methodparam"><span class="type">float</span> <code class="parameter">$height</code></span>
   , <span class="methodparam"><span class="type">float</span> <code class="parameter">$xstep</code></span>
   , <span class="methodparam"><span class="type">float</span> <code class="parameter">$ystep</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$painttype</code></span>
   )</div>

  <p class="para rdfs-comment">
   Starts a new pattern. A pattern is like a page containing e.g. a drawing
   which can be used for filling areas. It is used like a color by calling
   <span class="function"><a href="function.ps-setcolor.html" class="function">ps_setcolor()</a></span> and setting the color space to
   <em>pattern</em>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.ps-begin-pattern-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">psdoc</code></em></dt>

     <dd>

      <p class="para">
       Resource identifier of the postscript file
       as returned by <span class="function"><a href="function.ps-new.html" class="function">ps_new()</a></span>.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">width</code></em></dt>

     <dd>

      <p class="para">
       The width of the pattern in pixel.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">height</code></em></dt>

     <dd>

      <p class="para">
       The height of the pattern in pixel.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">x-step</code></em></dt>

     <dd>

      <p class="para">
       The distance in pixel of placements of the pattern in
       horizontal direction.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">y-step</code></em></dt>

     <dd>

      <p class="para">
       The distance in pixel of placements of the pattern in
       vertical direction.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">painttype</code></em></dt>

     <dd>

      <p class="para">
       Must be 1 or 2.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.ps-begin-pattern-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   The identifier of the pattern  或者在失败时返回 <strong><code>FALSE</code></strong>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.ps-begin-pattern-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3465">
    <p><strong>Example #1 Creating and using a pattern</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$ps&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ps_new</span><span style="color: #007700">();<br /><br />if&nbsp;(!</span><span style="color: #0000BB">ps_open_file</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"pattern.ps"</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;print&nbsp;</span><span style="color: #DD0000">"Cannot&nbsp;open&nbsp;PostScript&nbsp;file\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;exit;<br />}<br /><br /></span><span style="color: #0000BB">ps_set_parameter</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"warning"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"true"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_set_info</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Creator"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"pattern.php"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_set_info</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Author"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Uwe&nbsp;Steinmann"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_set_info</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Title"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Pattern&nbsp;example"</span><span style="color: #007700">);<br /><br /><br /></span><span style="color: #0000BB">$pspattern&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ps_begin_pattern</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">10.0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">10.0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">10.0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">10.0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_setlinewidth</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0.2</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_setcolor</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"stroke"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"rgb"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0.0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0.0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1.0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0.0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_moveto</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_lineto</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">7</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">7</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_stroke</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_moveto</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">7</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_lineto</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">7</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_stroke</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_end_pattern</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">ps_begin_page</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">596</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">842</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_setcolor</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"both"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"pattern"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$pspattern</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0.0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0.0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0.0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_rect</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">50</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">400</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">200</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">200</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_fill</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_end_page</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">ps_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_delete</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.ps-begin-pattern-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.ps-end-pattern.html" class="function" rel="rdfs-seeAlso">ps_end_pattern()</a> - End a pattern</span></li>
    <li class="member"><span class="function"><a href="function.ps-setcolor.html" class="function" rel="rdfs-seeAlso">ps_setcolor()</a> - Sets current color</span></li>
    <li class="member"><span class="function"><a href="function.ps-shading-pattern.html" class="function" rel="rdfs-seeAlso">ps_shading_pattern()</a> - Creates a pattern based on a shading</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.ps-begin-page.html">ps_begin_page</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.ps-begin-template.html">ps_begin_template</a></div>
 <div class="up"><a href="ref.ps.html">PS 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
